package com.shujia.utils;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

public class HbaseParameters {
    private static Connection conn = null;
    private static Admin admin = null;

    public static Connection getConnection(){

        try {
            //新版本创建配置文件对象的方式
            Configuration conf = HBaseConfiguration.create();
            //设置zookeeper的节点信息
            conf.set("hbase.zookeeper.quorum", "master:2181,node1:2181,node2:2181");
            //创建hbase连接对象
            conn =  ConnectionFactory.createConnection(conf);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static Admin getAdmin(){
        try {
            admin = conn.getAdmin();
        }catch (Exception e){
            e.printStackTrace();
        }

        return admin;
    }
}
